package cn.bluethink.eguan.core.entity;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Id;

import cn.bluethink.eguan.model.core.EgAction;
import cn.bluethink.eguan.model.core.EgActionType;
import cn.bluethink.eguan.model.core.EgOType;
import cn.bluethink.eguan.model.core.EgObject;
import cn.bluethink.eguan.model.core.EgUser;

/**
 * 动作查询结果实体
 * 联合被操作对象的发布位置和操作者
 * 
 * @author 苏州中科蓝迪公司所有(c)2016-2021
 * @version 0.2.0
 * @brief 驿馆+（EGUAN）
 * @note 修订历史：
 * 1、wanglei于2018/11/15设计并构建初始版本v0.2.0
 */
public class ActionEntity implements Serializable {

    private static final long serialVersionUID = 7816760241478101955L;

    // 动作ID
    @Id
    private Long aid;

    // 动作类型ID
    private Integer atid;

    /*
     *  被操作的对象信息
     */
    private Integer otype;

    private Long oid;

    private String oname;

    /*
     * 操作的结果对象信息
     */
    private Integer rtype;

    private Long roid;
    
    private String rname;

    // 操作结果
    private String rcontent;
    
    // 动作发生的位置对象类型
    private Integer posOtype;
    
    // 动作发生的位置对象ID
    private Long posOid;

    /*
     *  执行操作者信息
     */
    private Long uid;
    
    private String uname;
    
    private String avator;

    // 操作的时间
    private Date ctime;
    
    // 动作标识
    private Integer actFlag;
    
    /**
     * 转业务模型
     * 
     * @return
     */
    public EgAction createEgAction() {
        EgAction action = new EgAction();
        action.setAid(aid);
        action.setType(new EgActionType(atid, null));
        action.setObj(new EgObject(oid, oname, new EgOType(otype, null)));
        if(roid != null && rtype != null) {
            action.setResult(new EgObject(roid, rname, new EgOType(rtype, null)));
        } else {
            action.setResult(null);
        }
        action.setRcontent(rcontent);
        if(posOid != null && posOtype != null) {
            action.setPos(new EgObject(posOid, null, new EgOType(posOtype, null)));
        }
        action.setUser(new EgUser(uid, uname, avator));
        action.setTime(ctime);
        return action;
    }

    public Long getAid() {
        return aid;
    }

    public void setAid(Long aid) {
        this.aid = aid;
    }

    public Integer getAtid() {
        return atid;
    }

    public void setAtid(Integer atid) {
        this.atid = atid;
    }

    public Integer getOtype() {
        return otype;
    }

    public void setOtype(Integer otype) {
        this.otype = otype;
    }

    public Long getOid() {
        return oid;
    }

    public void setOid(Long oid) {
        this.oid = oid;
    }

    public String getOname() {
        return oname;
    }

    public void setOname(String oname) {
        this.oname = oname;
    }

    public Integer getRtype() {
        return rtype;
    }

    public void setRtype(Integer rtype) {
        this.rtype = rtype;
    }

    public Long getRoid() {
        return roid;
    }

    public void setRoid(Long roid) {
        this.roid = roid;
    }

    public String getRcontent() {
        return rcontent;
    }

    public void setRcontent(String rcontent) {
        this.rcontent = rcontent;
    }

    public Integer getPosOtype() {
        return posOtype;
    }

    public void setPosOtype(Integer posOtype) {
        this.posOtype = posOtype;
    }

    public Long getPosOid() {
        return posOid;
    }

    public void setPosOid(Long posOid) {
        this.posOid = posOid;
    }

    public Long getUid() {
        return uid;
    }

    public void setUid(Long uid) {
        this.uid = uid;
    }

    public String getUname() {
        return uname;
    }

    public void setUname(String uname) {
        this.uname = uname;
    }

    public String getAvator() {
        return avator;
    }

    public void setAvator(String avator) {
        this.avator = avator;
    }

    public Date getCtime() {
        return ctime;
    }

    public void setCtime(Date ctime) {
        this.ctime = ctime;
    }

	public String getRname() {
		return rname;
	}

	public void setRname(String rname) {
		this.rname = rname;
	}

    public Integer getActFlag() {
        return actFlag;
    }

    public void setActFlag(Integer actFlag) {
        this.actFlag = actFlag;
    }

}
